import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import topic2 from '../views/topic2.vue'
import login from '../views/login.vue'
import index from '../views/index.vue'
import topic4 from '../views/topic4.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path:'/topic2',
    name:'topic2',
    component:topic2
  },
  {path:"/login",component:login},
  {path:'/index',component:index},
  {path:"/layout",component:index,meta:{title:"首页"},children:[
    {path:"/",component:()=>import("../views/layout.vue")}
  ]},
  {path:"/order",meta:{title:"订单管理"},component:index,children:[
    {path:"/",redirect:"/order/list"},
    {path:"list",meta:{title:"订单列表"},component:()=>import("../views/orderlist.vue")},
    {path:"detail",name:"detail",meta:{title:"订单详情"},component:()=>import("../views/orderdetail.vue")}
  ]},
  {path:"/shop",meta:{title:"店铺管理",roles:['super']},component:index,children:[
    {path:"/",component:()=>import("../views/shopindex.vue")}
  ]},
  {path:"/users",component:index,meta:{title:"账号管理",roles:['super','normal']},children:[
    {path:"/",redirect:"/users/list"},
    {path:"list",meta:{title:"账号列表",roles:['super']},component:()=>import("../views/userlist.vue")},
    {path:"my",meta:{title:"个人中心"},component:()=>import("../views/usermy.vue")},
    {path:"save",meta:{title:"添加账号",roles:['super']},component:()=>import("../views/usersave.vue")},
    {path:"pwd", meta:{title:"修改密码"},component:()=>import("../views/userpwd.vue")}
  ]},
  {path:"/goods", meta:{title:"商品管理",roles:['super','normal']},component:index,children:[
    {path:"/",redirect:"/goods/list"},
    {path:"list",meta:{title:"商品列表"},component:()=>import("../views/goodslist.vue")},
    {path:"save",meta:{title:"添加商品"},component:()=>import("../views/goodssave.vue")},
    {path:"type",meta:{title:"商品类型",roles:['super']},component:()=>import("../views/goodstype.vue")}
  ]},
  {path:"/census",meta:{title:"统计管理",roles:['super']},component:index,children:[
    {path:"/",redirect:"/census/ordercensus"},
    {path:"goodscensus",meta:{title:"商品统计"},component:()=>import("../views/goodscensus.vue")},
    {path:"ordercensus",meta:{title:"订单统计"},component:()=>import("../views/ordercensus.vue")}
  ]},
  {path:"/topic4",name:'topic4',component:topic4}
]

const router = new VueRouter({
  routes
})

export default router
